import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
const useGlobalStore = defineStore('globalStore', () => {
  const requestNumber = ref(0)
  const isLoading = computed(() => requestNumber.value > 0)
  const canvasFix = ref(false)
  /**开始请求 */
  const startRequest = () => {
    requestNumber.value++
  }
  /**结束请求 */
  const endRequest = () => {
    requestNumber.value--
  }
  const setCanvasFix = (fix: boolean) => {
    canvasFix.value = fix
  }
  return {
    isLoading,
    startRequest,
    endRequest,
    setCanvasFix,
    canvasFix,
  }
})

export default useGlobalStore
